<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>模版方法模式</title>
	</head>

	<body>
		<script type="text/javascript">
			var gameCenter = function() {}
			gameCenter.prototype.init = function() {
				this.login();
				this.gameStart();
				this.end();
			}
			gameCenter.prototype.login = function() {
				//do something
			}
			gameCenter.prototype.gameStart = function() {
				//空函数, 留给子类去重写
			}
			gameCenter.prototype.end = function() {
				alert("欢迎下次再来玩");
			}
			
			var crossfire=function(){
			}
			crossfire.prototype=gameCenter.prototype;  //继承
			crossfire.prototype.gameStart=function(){
			  //do something
			}
			(new crossfire()).init();
		</script>
	</body>

</html>